class Solution {
public:
    int takeAttendance(vector<int>& nums) {
        int sz=nums.size();
        int l=0;
        int r=sz;
        while(l<r)
        {
            int m=l+(r-l)/2;
            if(nums[m]>m||nums[m]>m)
                r=m;
            else if(nums[m]==m)
                l=m+1;
        }
        return r;
    }
};
